package com.yuyou.tas.feedback.service.impl;

import com.yuyou.tas.feedback.mapper.FeedbackMapper;
import com.yuyou.tas.feedback.mapper.FeedbackSituationMapper;
import com.yuyou.tas.feedback.service.IFeedbackSituationService;
import com.yuyou.tas.service.api.feedback.dto.FeedbackDetailDTO;
import com.yuyou.tas.service.api.feedback.dto.FeedbackSituationMoreVo;
import com.yuyou.tas.service.api.feedback.entity.FeedbackSituation;
import com.yuyou.tas.util.enums.feedback.FeedbackSituationEnums;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeedbackSituationServiceImpl implements IFeedbackSituationService {

    @Autowired
    private FeedbackSituationMapper mapper;

    @Autowired
    private FeedbackMapper feedbackMapper;


    @Override
    public int deleteByPrimaryKey(Long id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(FeedbackSituation record) {
        return mapper.insert(record);
    }

    @Override
    public FeedbackSituation selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(FeedbackSituation record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public void delByFeedId(Long feedbackId) {
        mapper.delByFeedId(feedbackId);
    }

    @Override
    public FeedbackDetailDTO findSituationByFeedbackId(Long feedbackId) {
        FeedbackDetailDTO feedbackDetailDTO = feedbackMapper.findInfoOfFeedback(feedbackId);
        feedbackDetailDTO.setBehaviourList(mapper.findSituationByFeedbackIdType(feedbackId, FeedbackSituationEnums.type.behaviour.getValue()));
        feedbackDetailDTO.setContentList(mapper.findSituationByFeedbackIdType(feedbackId, FeedbackSituationEnums.type.content.getValue()));
        feedbackDetailDTO.setVoiceList(mapper.findSituationByFeedbackIdType(feedbackId, FeedbackSituationEnums.type.voice.getValue()));
        feedbackDetailDTO.setPictureList(mapper.findSituationByFeedbackIdType(feedbackId, FeedbackSituationEnums.type.picture.getValue()));
        return feedbackDetailDTO;
    }

    @Override
    public List<FeedbackSituationMoreVo> findByFeedbackClassId(Long feedbackClassId) {
        return mapper.findByFeedbackClassId(feedbackClassId);
    }

    @Override
    public List<FeedbackSituation> findAllNeedOperate() {
        return mapper.findAllNeedOperate();
    }
}